#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Taotie Ren
# import logging 
# 禁用日志模块
# logging.disable(logging.CRITICAL)
# logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s')

# updateProduce.py -  Corrects costs in produce sales spreadsheet.

import openpyxl

wb = openpyxl.load_workbook('.\\openpyxl\\produceSales.xlsx')
sheet = wb.get_sheet_by_name('Sheet')

# The produce types and their updated prices.
PRICE_UPDATES = {
	'Garlic': 3.07,
	'Celery': 1.19,
	'Lemon': 1.27
}
# Loop through the rows ad update the prices.
for rowNum in range(2, sheet.max_row):  # Ship the frist row
	produceName = sheet.cell(row=rowNum, column=1).value
	if produceName in PRICE_UPDATES:
		sheet.cell(row=rowNum, column=2).value = PRICE_UPDATES[produceName]

wb.save('.\\openpyxl\\updatedProduceSales.xlsx')

import PyPDF2, docx

pdfFile = open('test.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFile)
pdfWriter = PyPDF2.PdfFileWriter()

for pageNum in range(pdfReader.numPages):
	pdfObj = pdfReader.getPage(pageNum)
	pdfWriter.addPage(pageObj)

pdfOutputFile = open('ok.pdf', 'wb')
pdfWriter.write(pdfOutputFile)
pdfOutputFile.close()
pdfFile.close()
